package com.huawei.appmarket.framework.activity;

import android.app.ActionBar;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import com.huawei.android.app.ActionBarEx;
import com.huawei.appgallery.foundation.ui.framework.activity.AbstractBaseActivity;
import com.huawei.appmarket.framework.activity.AppWelfareListActivityProtocol.Request;
import com.huawei.appmarket.framework.fragment.AppWelfareListFragment;
import o.azb;
import o.azc;
import o.bsm;
import o.cgv;
import o.cjk;
import o.cjm;
import o.dgh;
import o.Logger;
import o.dof;
import o.ean;
import o.ewm.c;
import o.ewm.e;
import o.ewm.h;
import o.ewm.j;
import o.ewm.n;
import o.FragmentTransaction;

public class AppWelfareListActivity extends AbstractBaseActivity<AppWelfareListActivityProtocol> implements bsm {
    private long ʻॱ;
    private boolean ˊॱ;
    private String ˋॱ;
    private int ˏॱ = -1;
    private View ͺ;
    private String ॱˊ;
    private TextView ॱˋ;
    private boolean ॱˎ = false;
    private int ᐝॱ = -1;

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(h.ॱˎ);
        if (bundle != null) {
            this.ॱˎ = bundle.getBoolean("key_menu");
        }
        AppWelfareListActivityProtocol appWelfareListActivityProtocol = (AppWelfareListActivityProtocol) ʾ();
        if (appWelfareListActivityProtocol != null && appWelfareListActivityProtocol.ˏ() != null) {
            ॱ(appWelfareListActivityProtocol);
            ˊ(appWelfareListActivityProtocol);
        }
    }

    public void onResume() {
        super.onResume();
        this.ʻॱ = dgh.ॱ();
    }

    public void onPause() {
        super.onPause();
        AppWelfareListActivityProtocol appWelfareListActivityProtocol = (AppWelfareListActivityProtocol) ʾ();
        if (appWelfareListActivityProtocol != null && appWelfareListActivityProtocol.ˏ() != null) {
            ean.ˏ(appWelfareListActivityProtocol.ˏ().ʽ(), System.currentTimeMillis() - this.ʻॱ, ʿ());
        }
    }

    private void ˊ(AppWelfareListActivityProtocol appWelfareListActivityProtocol) {
        AppWelfareListFragment appWelfareListFragment = (AppWelfareListFragment) cjk.ˎ().ˊ(new cjm("app.welfare.fragment", appWelfareListActivityProtocol));
        if (appWelfareListFragment != null) {
            try {
                FragmentTransaction ˊ = ˏॱ().ˊ();
                ˊ.ˏ(j.ʳ, appWelfareListFragment, "app.welfare.fragment");
                ˊ.ˋ();
            } catch (ArrayIndexOutOfBoundsException e) {
                Logger.ˋ("AppWelfareListActivity", e.toString());
            }
        }
    }

    private void ॱ(AppWelfareListActivityProtocol appWelfareListActivityProtocol) {
        this.ͺ = findViewById(j.ﹶ);
        azb.ˏ(this.ͺ);
        this.ॱˋ = (TextView) this.ͺ.findViewById(j.ˈˉ);
        Request ˏ = appWelfareListActivityProtocol.ˏ();
        this.ˏॱ = ˏ.ˎ();
        this.ॱˊ = ˏ.ॱ();
        this.ˊॱ = ˏ.ˋ();
        this.ˋॱ = ˏ.ˊ();
        this.ᐝॱ = ˏ.ᐝ();
        ͺ();
    }

    private void ͺ() {
        if (azc.ˎ().ॱ() >= 21) {
            ॱˊ();
        } else {
            ᐝॱ();
        }
        cgv.ˋ(this, c.ˎ, c.ॱˎ);
    }

    public void ˏ(String str) {
        this.ˋॱ = str;
        if (dof.ॱ(str)) {
            str = getString(n.ᐝॱ);
        }
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.setTitle(str);
        }
        if (this.ॱˋ != null) {
            this.ॱˋ.setText(str);
        }
    }

    private void ॱˊ() {
        this.ͺ.setVisibility(8);
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.setDisplayOptions(12);
            actionBar.setDisplayShowCustomEnabled(false);
            actionBar.show();
            if (dof.ॱ(this.ˋॱ)) {
                actionBar.setTitle(n.ᐝॱ);
            } else {
                actionBar.setTitle(this.ˋॱ);
            }
        }
        if (this.ˊॱ) {
            ActionBarEx.setEndIcon(actionBar, true, getResources().getDrawable(this.ˏॱ), new OnClickListener(this) {
                final /* synthetic */ AppWelfareListActivity ˋ;

                {
                    this.ˋ = r1;
                }

                public void onClick(View view) {
                    this.ˋ.ˉ();
                }
            });
            if (this.ᐝॱ > 0) {
                try {
                    getWindow().getDecorView().findViewById(16908296).setContentDescription(getString(this.ᐝॱ));
                } catch (Exception e) {
                    Logger.e("AppWelfareListActivity", "setContentDescription error");
                }
            }
        } else if (this.ॱˎ) {
            ᐝ();
        } else {
            ActionBarEx.setEndIcon(actionBar, false, null, null);
        }
    }

    private void ᐝॱ() {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        if (dof.ॱ(this.ˋॱ)) {
            this.ॱˋ.setText(n.ᐝॱ);
        } else {
            this.ॱˋ.setText(this.ˋॱ);
        }
        findViewById(j.ʼㆍ).setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ AppWelfareListActivity ˊ;

            {
                this.ˊ = r1;
            }

            public void onClick(View view) {
                this.ˊ.onBackPressed();
            }
        });
        ImageView imageView = (ImageView) findViewById(j.ʽᐨ);
        View findViewById = findViewById(j.ʼꓸ);
        if (this.ˊॱ) {
            findViewById.setVisibility(0);
            imageView.setBackgroundResource(this.ˏॱ);
            if (this.ᐝॱ > 0) {
                findViewById.setContentDescription(getString(this.ᐝॱ));
            }
            findViewById.setOnClickListener(new OnClickListener(this) {
                final /* synthetic */ AppWelfareListActivity ˊ;

                {
                    this.ˊ = r1;
                }

                public void onClick(View view) {
                    this.ˊ.ˉ();
                }
            });
        } else if (this.ॱˎ) {
            ᐝ();
        } else {
            findViewById.setVisibility(8);
        }
    }

    public String ʿ() {
        AppWelfareListActivityProtocol appWelfareListActivityProtocol = (AppWelfareListActivityProtocol) ʾ();
        if (appWelfareListActivityProtocol == null || appWelfareListActivityProtocol.ˏ() == null) {
            return null;
        }
        return appWelfareListActivityProtocol.ˏ().ˏ();
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (16908332 != menuItem.getItemId()) {
            return super.onOptionsItemSelected(menuItem);
        }
        finish();
        return true;
    }

    public void ᐝ() {
        int i = e.ˊʽ;
        Drawable drawable = getResources().getDrawable(i);
        if (azc.ˎ().ॱ() >= 21) {
            ActionBarEx.setEndIcon(getActionBar(), true, drawable, ʼॱ());
            try {
                getWindow().getDecorView().findViewById(16908296).setContentDescription(getString(n.ͺꜟ));
                return;
            } catch (Exception e) {
                Logger.e("AppWelfareListActivity", "setContentDescription error");
                return;
            }
        }
        View findViewById = this.ͺ.findViewById(j.ʼꓸ);
        findViewById.setVisibility(0);
        ((ImageView) findViewById.findViewById(j.ʽᐨ)).setImageResource(i);
        findViewById.setContentDescription(getString(n.ͺꜟ));
        findViewById.setOnClickListener(ʼॱ());
    }

    private OnClickListener ʼॱ() {
        return new OnClickListener(this) {
            final /* synthetic */ AppWelfareListActivity ˎ;

            {
                this.ˎ = r1;
            }

            public void onClick(View view) {
                this.ˎ.ˉ();
            }
        };
    }

    private void ˉ() {
        cjk.ˎ().ˋ(this, new cjm("myaward_activity", null));
    }

    public void onSaveInstanceState(Bundle bundle) {
        bundle.putBoolean("key_menu", this.ॱˎ);
        super.onSaveInstanceState(bundle);
    }
}
